package metalink.admin;

import com.opensymphony.xwork2.ActionSupport;

import java.util.*;
import java.sql.*;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import vo.*;
import vo.mixed.*;
import model.admin.*;
import myutil.*;

public class QueryBuilderNew extends ActionSupport{
ArrayList<String> arr=new ArrayList<String>();
private ArrayList<String> saved_queries=new ArrayList<String>();
private ArrayList<String> saved_queries_ids=new ArrayList<String>();
	public String execute(){
		try{
			HttpSession session = ServletActionContext.getRequest().getSession();
			String username = session.getAttribute("username").toString();
			arr.add("Batch");
			arr.add("Course");
			arr.add("Department");
			arr.add("Degree");
			arr.add("Student");
			arr.add("Staff");
			arr.add("Hostel");
			arr.add("Library");
			arr.add("Placement");
			Connect c=new Connect();
			ResultSet rs;
			 rs=c.getResult("select * from saved_queries where username='"+username+"'");
	            while(rs.next()){
	            	saved_queries_ids.add(rs.getString("query_id"));
	            	saved_queries.add(rs.getString("query"));
	            }
			return SUCCESS;
			
			
		}
		catch(Exception e){
			e.printStackTrace();
			return ERROR;
		}
	}
	public ArrayList<String> getArr() {
		return arr;
	}
	public void setArr(ArrayList<String> arr) {
		this.arr = arr;
	}
	public ArrayList<String> getSaved_queries() {
		return saved_queries;
	}

	public void setSaved_queries(ArrayList<String> saved_queries) {
		this.saved_queries = saved_queries;
	}
	public ArrayList<String> getSaved_queries_ids() {
		return saved_queries_ids;
	}
	public void setSaved_queries_ids(ArrayList<String> saved_queries_ids) {
		this.saved_queries_ids = saved_queries_ids;
	}
}
